package main

import (
	"fmt"
	"workspace/easy"
	"workspace/hard"
	"workspace/mid"
	"workspace/node"
)

func MinimumAddedCoins() {
	coins := []int{1, 1, 1}
	target := 20
	res := mid.MinimumAddedCoins(coins, target)
	fmt.Printf("结果：%d\n", res)

}
func AllPossibleFBT() {
	res := mid.AllPossibleFBT(3)
	for _, tree := range res {
		fmt.Print("树的结果：")
		mid.PreOrderTraversal(tree)
		fmt.Println()
	}
}
func finalString() {
	s := "poixyinter"
	res := easy.FinalString(s)
	fmt.Printf("结果：%s\n", res)

}

func binaryTreePaths() {
	root := &node.TreeNode{
		Val: 10,
		Left: &node.TreeNode{
			Val: 5,
		},
		Right: &node.TreeNode{
			Val: 15,
		},
	}
	paths := easy.BinaryTreePaths(root)
	for _, path := range paths {
		fmt.Println(path)
	}
}

func addDigits() {
	res := easy.AddDigits(12)
	fmt.Printf("res: %d ", res)
}

func missingNumber() {
	nums := []int{1, 0, 3}
	res := easy.MissingNumber(nums)
	fmt.Printf("%d", res)
}
func isUgly() {
	res := easy.IsUgly(13)
	fmt.Printf("%t ", res)
}
func getTargetCopy() {
	// 创建一个二叉树
	original := &node.TreeNode{Val: 1}
	original.Left = &node.TreeNode{Val: 2}
	original.Right = &node.TreeNode{Val: 3}
	original.Left.Left = &node.TreeNode{Val: 4}
	original.Left.Right = &node.TreeNode{Val: 5}

	// 克隆二叉树
	cloned := &node.TreeNode{Val: 1}
	cloned.Left = &node.TreeNode{Val: 2}
	cloned.Right = &node.TreeNode{Val: 9}
	cloned.Left.Left = &node.TreeNode{Val: 4}
	cloned.Left.Right = &node.TreeNode{Val: 5}
	target := &node.TreeNode{Val: 3}
	result := easy.GetTargetCopy(original, cloned, target)
	if result != nil {
		fmt.Printf("找到目标节点: %v\n", result.Val)
	} else {
		fmt.Println("未找到目标节点的")
	}
}
func preorderTraversal(root *node.TreeNode) {
	if root == nil {
		return
	}
	// 访问根节点
	fmt.Println(root.Val)
	// 遍历左子树
	preorderTraversal(root.Left)
	// 遍历右子树
	preorderTraversal(root.Right)
}

func minOperations() {
	nums := []int{1, 5, 4, 44}
	res := hard.MinOperations(nums)
	fmt.Printf("%d", res)
}

func moveZeroes() {
	nums := []int{0, 1, 0, 2}
	easy.MoveZeroes(nums)
	for _, num := range nums {
		fmt.Printf("%d   ", num)
	}
}
func wordPattern() {
	pattern := "abba"
	s := "sss dtd ddd sss"
	flag := easy.WordPattern(pattern, s)
	fmt.Printf("%t", flag)
}

func maximumCount() {
	nums := []int{-1, -2, 0, 1, 1, 2, 3}
	res := easy.MaximumCount(nums)
	fmt.Printf("%d", res)
}

func getHint() {
	secret := "0189"
	guess := "0198"
	res := easy.GetHint(secret, guess)
	fmt.Printf("%s", res)
}

func maximumBinaryString() {
	s := "000110"
	res := mid.MaximumBinaryString1(s)
	fmt.Printf("%s", res)
}

func reverseString() {
	str := []byte{'s', 'c', 'v'}
	easy.ReverseString(str)
	fmt.Printf("%s", str)
}

func reverseVowels() {
	str := "hello"
	res := easy.ReverseVowels(str)
	fmt.Printf("%s", res)
}
func canConstruct() {
	str1 := "adc"
	str2 := "anxxc"
	flag := easy.CanConstruct(str1, str2)
	fmt.Printf("%t", flag)
}

func firstUniqChar() {
	str := "sssbccccsg"
	res := easy.FirstUniqChar(str)
	fmt.Printf("%d", res)
}

func findTheDifference() {
	s := "abc"
	t := "abcd"
	res := easy.FindTheDifference2(s, t)
	fmt.Printf("%c", res)
}

func isSubsequence() {
	s := "abc"
	t := "ahcgcc"
	res := easy.IsSubsequence(s, t)
	fmt.Printf("%t", res)
}
func findChampion() {
	grid := [][]int{{0, 0, 1}, {1, 0, 1}, {0, 0, 0}}
	res := easy.FindChampion(grid)
	fmt.Printf("%d", res)
}

func toHex() {
	res := easy.ToHex(27)
	fmt.Printf("%s", res)
}

func longestPalindrome() {
	str := "zzzzoooa"
	res := easy.LongestPalindrome(str)
	fmt.Printf("%d", res)
}

func thirdMax() {
	arr := []int{3, 2, 2, 1}
	res := easy.ThirdMax(arr)
	fmt.Printf("%d", res)
}

func addStrings() {
	num1 := "123"
	num2 := "456"
	res := easy.AddStrings(num1, num2)
	fmt.Printf("%s", res)
}

func findOriginalArray() {
	changed := []int{0, 1, 2}
	res := mid.FindOriginalArray(changed)
	for _, num := range res {
		fmt.Printf("%d", num)
		fmt.Print("=====")
	}
}

func maxSatisfied() {
	customers := []int{1, 0, 1, 2, 1, 1, 7, 5}
	grumpy := []int{0, 1, 0, 1, 0, 1, 0, 1}
	minutes := 3
	res := mid.MaxSatisfied(customers, grumpy, minutes)
	fmt.Printf("%d", res)
}

func countSegments() {
	s := "my name is li"
	res := easy.CountSegments(s)
	fmt.Printf("%d", res)
}

func arrangeCoins() {
	n := 3
	res := easy.ArrangeCoins(n)
	fmt.Printf("%d", res)
}

func numberOfBoomerangs() {
	points := [][]int{{0, 0}, {1, 0}, {2, 0}}
	res := easy.NumberOfBoomerangs(points)
	fmt.Printf("%d", res)
}

func findDisappearedNumbers() {
	nums := []int{1, 1, 3, 4, 3, 4}
	res := easy.FindDisappearedNumbers(nums)
	for _, v := range res {
		fmt.Printf("%d", v)
		fmt.Println()
	}
}

func minMoves() {
	nums := []int{1, 2, 3}
	res := easy.MinMoves(nums)
	fmt.Printf("%d", res)
}

func findContentChildren() {
	g := []int{1, 2, 3}
	s := []int{1, 1}
	res := easy.FindContentChildren(g, s)
	fmt.Printf("%d", res)
}

func repeatedSubstringPattern() {
	s := "abab"
	flag := easy.RepeatedSubstringPattern(s)
	fmt.Printf("%t", flag)
}

func hammingDistance() {
	x := 1
	y := 4
	res := easy.HammingDistance(x, y)
	fmt.Printf("%d", res)
}

func distanceTraveled() {
	mainTank := 5
	additionalTank := 10
	res := easy.DistanceTraveled1(mainTank, additionalTank)
	fmt.Printf("%d", res)
}

func islandPerimeter() {
	grid := [][]int{{0, 1, 0, 0}, {1, 1, 1, 0}, {0, 1, 0, 0}, {1, 1, 0, 0}}
	res := easy.IslandPerimeter(grid)
	fmt.Printf("%d", res)
}

func findRadius() {
	houses := []int{1, 2, 3}
	heart := []int{2}
	res := easy.FindRadius(houses, heart)
	fmt.Printf("%d", res)
}
func licenseKeyFormatting() {
	s := "5F3Z-2e-9-w"
	k := 4
	res := easy.LicenseKeyFormatting(s, k)
	fmt.Printf("%s", res)
}
func findMaxConsecutiveOnes() {
	nums := []int{1, 1, 0, 0, 1, 1, 1}
	res := easy.FindMaxConsecutiveOnes(nums)
	fmt.Printf("%d", res)
}

func nextGreaterElement() {
	nums1 := []int{4, 1, 2}
	nums2 := []int{1, 3, 4, 2}
	res := easy.NextGreaterElement(nums1, nums2)
	for _, num := range res {
		fmt.Printf("%d", num)
		fmt.Println()
	}
}

func wateringPlants() {
	plants := []int{2, 2, 3, 3}
	capacity := 5
	res := mid.WateringPlants(plants, capacity)
	fmt.Printf("%d", res)

}

func checkPerfectNumber() {
	num := 28
	res := easy.CheckPerfectNumber(num)
	fmt.Printf("%t", res)
}

func minimumRefill() {
	plants := []int{2, 2, 3, 3}
	capacityA := 5
	capacityB := 5
	res := mid.MinimumRefill(plants, capacityA, capacityB)
	fmt.Printf("%d", res)
}

func countTestedDevices() {
	batteryPercentages := []int{1, 1, 2, 1, 3}
	res := easy.CountTestedDevices(batteryPercentages)
	fmt.Printf("%d", res)
}

func constructRectangle() {
	area := 14
	res := easy.ConstructRectangle(area)
	fmt.Printf("%d", res)
}

func findPoisonedDuration() {
	timeSeries := []int{1, 4}
	duration := 2
	res := easy.FindPoisonedDuration(timeSeries, duration)
	fmt.Printf("%d", res)
}

func garbageCollection() {
	garbage := []string{"G", "P", "GP", "GG"}
	travel := []int{2, 4, 3}
	res := mid.GarbageCollection(garbage, travel)
	fmt.Printf("%d", res)
}

func findMode() {
	// 创建一个二叉树
	original := &node.TreeNode{Val: 1}
	original.Right = &node.TreeNode{Val: 2}
	original.Right.Left = &node.TreeNode{Val: 2}
	res := easy.FindMode(original)
	fmt.Printf("%d", res)
}

func getMinimumDifference() {
	// 创建一个二叉树
	original := &node.TreeNode{Val: 1}
	original.Right = &node.TreeNode{Val: 5}
	original.Right.Left = &node.TreeNode{Val: 2}
	res := easy.GetMinimumDifference(original)
	fmt.Printf("%d", res)

}

func maxScore() {
	nums := []int{2, 3, 6, 1, 9, 2}
	x := 5
	res := mid.MaxScore(nums, x)
	fmt.Printf("%d", res)

}

func maxDistToClosest() {
	seats := []int{1, 0, 0, 0, 1, 0, 1}
	res := easy.MaxDistToClosest(seats)
	fmt.Printf("%d", res)
}
func buddyStrings() {
	s := "ab"
	goal := "bb"
	res := easy.BuddyStrings(s, goal)
	fmt.Printf("%t", res)

}

func commonChars() {
	words := []string{"bella", "label", "roller"}
	res := easy.CommonChars(words)
	fmt.Printf("%s", res)

}

func findTilt() {
	original := &node.TreeNode{Val: 1}
	original.Left = &node.TreeNode{Val: 2}
	original.Right = &node.TreeNode{Val: 3}
	//original.Left.Left = &node.TreeNode{Val: 4}
	//original.Left.Right = &node.TreeNode{Val: 5}
	res := easy.FindTilt(original)
	fmt.Printf("%d", res)
}

func addedInteger() {
	nums1 := []int{2, 6, 4}
	nums2 := []int{9, 7, 5}
	res := easy.AddedInteger(nums1, nums2)
	fmt.Printf("%d", res)

}

func imageSmoother() {
	nums := [][]int{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}
	res := easy.ImageSmoother(nums)
	fmt.Printf("%d", res)
}
func main() {
	imageSmoother()
}
